package top.infopub.mgr.sys.web;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import top.infopub.generic.GenericController;
import top.infopub.mgr.common.page.ParamPage;
import top.infopub.mgr.common.vo.RspVo;
import top.infopub.mgr.sys.service.BusinessParameterService;
import top.infopub.model.sys.BusinessParameter;

import com.github.pagehelper.Page;


/**
 * 业务参数管理
 * @author Awoke
 * @version 2018年10月15日
 * @see BusinessParaController
 * @since
 */
@Controller
@RequestMapping("/businessPara")
public class BusinessParaController extends GenericController {

    @Autowired
    private BusinessParameterService businessParameterService;

    /**
     * 进入业务参数管理
     */
    @RequestMapping("/list")
    public String list() {
        return "paraMgr/laybusiparam-list";
    }

    /**
     * 查询业务参数
     */
    @RequestMapping("/queryDataByCondition")
    public @ResponseBody RspVo<BusinessParameter> queryDataByCondition(BusinessParameter busPara, ParamPage page) {
        
    	Page<BusinessParameter> p = new Page<BusinessParameter>(page.getPage(), page.getLimit());
    	Page<BusinessParameter> businessParamsPage = businessParameterService.selectBusinessParaByCondition(busPara, p);
    	return RspVo.getSuccessResponse(businessParamsPage.getTotal(), businessParamsPage.getResult());
    }

    /**
     * 批量删除业务参数
     * @param checkboxId
     */
    @SuppressWarnings("rawtypes")
    @RequestMapping("/delete")
    public @ResponseBody RspVo delete(String[] checkboxId) {
        businessParameterService.batchDeleteByIds(checkboxId);
        return RspVo.getSuccessResponse();
    }

    /**
     * 新增业务参数
     * @param businessParameter
     */
    @SuppressWarnings("rawtypes")
    @RequestMapping("/insert")
    public @ResponseBody RspVo insert(BusinessParameter businessParameter) {
        businessParameterService.insert(businessParameter);
        return RspVo.getSuccessResponse();
    }

    /**
     * 修改业务参数
     * @param checkboxId
     */
    @SuppressWarnings("rawtypes")
    @RequestMapping("/update")
    public @ResponseBody RspVo update(BusinessParameter businessParameter) {
        businessParameterService.updateByPrimaryKey(businessParameter);
        return RspVo.getSuccessResponse();
    }

}
